package com.huawei.appmarket.service.settings.view.fragment;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.HeaderViewListAdapter;
import com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.BaseListFragment;
import com.huawei.appgallery.foundation.ui.framework.cardkit.widget.CardListAdapter;
import com.huawei.appmarket.service.settings.bean.BaseSettingCardBean;
import com.huawei.hms.common.data.DataBufferSafeParcelable;
import com.huawei.secure.android.common.intent.SafeBroadcastReceiver;
import java.lang.ref.WeakReference;
import o.cia;
import o.der.g;
import o.der.i;
import o.Logger;
import o.ContentManager;
import o.egw;
import o.ll;

public class SettingsFragment extends BaseListFragment {
    public static final String ˊ = (ˎ + ".settings.REFRESH_LIST_DATA");
    public static final String ˋ = (ˎ + ".settings.REFRESH_LIST");
    public static final String ˎ = ContentManager.getInstant().getContext().getPackageName();
    private BroadcastReceiver ˏ = new SafeBroadcastReceiver(this) {
        final /* synthetic */ SettingsFragment ˋ;

        {
            this.ˋ = r1;
        }

        public void onReceiveMsg(Context context, Intent intent) {
            String action = intent.getAction();
            Logger.ˏ("SettingsFragment", "onReceive " + action);
            if (SettingsFragment.ˊ.equals(action)) {
                int intExtra = intent.getIntExtra("requestCode", -1);
                int intExtra2 = intent.getIntExtra("resultCode", 0);
                Intent intent2 = (Intent) intent.getParcelableExtra(DataBufferSafeParcelable.DATA_FIELD);
                BaseSettingCardBean baseSettingCardBean = new BaseSettingCardBean();
                baseSettingCardBean.ʽ(intExtra);
                baseSettingCardBean.ʼ(intExtra2);
                baseSettingCardBean.ˎ(intent2);
                if (Logger.ˎ()) {
                    Logger.ˏ("SettingsFragment", "requestCode=" + baseSettingCardBean.ꜞ() + ",result=" + baseSettingCardBean.ㆍ() + ",data=" + baseSettingCardBean.ꓸ());
                }
                Message obtainMessage = this.ˋ.ॱ.obtainMessage(1);
                obtainMessage.obj = baseSettingCardBean;
                this.ˋ.ॱ.sendMessage(obtainMessage);
            } else if (SettingsFragment.ˋ.equals(action)) {
                this.ˋ.ॱ.sendEmptyMessage(2);
            } else if ("com.huawei.appmarket.service.broadcast.AgeAbtained".equals(action)) {
                egw.ˏ().ˋ(context, this.ˋ.י, this.ˋ.ˉॱ());
            }
        }
    };
    private e ॱ;

    class e extends Handler {
        private WeakReference<SettingsFragment> ˏ;
        final /* synthetic */ SettingsFragment ॱ;

        public e(SettingsFragment settingsFragment, SettingsFragment settingsFragment2) {
            this.ॱ = settingsFragment;
            this.ˏ = new WeakReference(settingsFragment2);
        }

        public void handleMessage(Message message) {
            if (((SettingsFragment) this.ˏ.get()) != null) {
                switch (message.what) {
                    case 1:
                        egw.ˏ().ˎ(this.ॱ.י, (BaseSettingCardBean) message.obj);
                        this.ॱ.ˊʻ();
                        return;
                    case 2:
                        this.ॱ.ˊʻ();
                        return;
                    default:
                        return;
                }
            }
        }
    }

    public cia ˊ(Context context) {
        cia ˏ = egw.ˏ().ˏ(context, ˉॱ());
        ˏ.ˊ(false);
        return ˏ;
    }

    protected int ˉॱ() {
        return i.ˏ;
    }

    public void ˏ(Bundle bundle) {
        this.ॱ = new e(this, this);
        ॱˋ(true);
        super.ˏ(bundle);
    }

    public View ˋ(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        View ˋ = super.ˋ(layoutInflater, viewGroup, bundle);
        ˋॱ(true);
        return ˋ;
    }

    public void ᵔ() {
        ˎ(this.ॱˍ);
    }

    public int ߵ() {
        return g.ˊॱ;
    }

    public void ˌॱ() {
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(ˊ);
        intentFilter.addAction(ˋ);
        intentFilter.addAction("com.huawei.appmarket.service.broadcast.AgeAbtained");
        ll.ˏ(ॱˋ()).ˏ(this.ˏ, intentFilter);
    }

    public void ˋʼ() {
        ll.ˏ(ॱˋ()).ˋ(this.ˏ);
    }

    private void ˊʻ() {
        CardListAdapter cardListAdapter = null;
        if (this.ͺˎ != null) {
            if (this.ͺˎ.getAdapter() instanceof HeaderViewListAdapter) {
                cardListAdapter = (CardListAdapter) ((HeaderViewListAdapter) this.ͺˎ.getAdapter()).getWrappedAdapter();
            } else {
                cardListAdapter = (CardListAdapter) this.ͺˎ.getAdapter();
            }
        }
        if (cardListAdapter != null && cardListAdapter.getCount() > 0) {
            cardListAdapter.notifyDataSetChanged();
        }
    }
}
